<?php
/*
 **************************************************************************************************
 *	The template for displaying author archive pages
 **************************************************************************************************
*/
?>

<?php get_header(); ?><!-- load header.php -->

<section id="content">
	<div class="container">
		<div class="row">
			<!-- main content area -->
			<div class="span8">
			<!-- checks if the current wordpress query has any results to loop over -->
			<?php if ( have_posts() ) : ?>
				<?php
					/*
					 * queue the first post, that way we know what author we are dealing with (if that is the case)
					 * we reset this later so we can run the loop properly with a call to rewind_posts()
					 */
					the_post();
				?>
				<h1 class="archive-title">
					<?php printf( __( 'All posts by %s', TEXTDOMAIN ), '<span class="vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" title="' . esc_attr( get_the_author() ) . '" rel="me">' . get_the_author() . '</a></span>' ); ?>
				</h1>
				<?php
					/*
					 * since we called the_post() above, we need to rewind the loop back to the beginning that way
					 * we can run the loop properly, in full
					 */
					rewind_posts();
				?>
				<?php
					if ( get_the_author_meta( 'description' ) ) :
						get_template_part( 'author-bio' );
					endif;
				?>
				<div class="blankline30"></div>
			<?php
					while ( have_posts() ) :
						// iterate the post index in the loop
						the_post();
						// load a template part ( load content-{post_format}.php )
						get_template_part( 'content', get_post_format() );
					endwhile;

					// paging navigation
					if ( function_exists( 'wp_pagenavi' ) ) :
						wp_pagenavi(); // pagenavi plugin
					else :
						prototype_paging_nav();
					endif;
				else :
					// load content-none.php
					get_template_part( 'content', 'none' );
				endif;
			?>
			</div>
			<!-- sidebar area -->
			<div class="span4">
				<aside class="right-sidebar">
					<?php get_sidebar(); ?><!-- load sidebar.php -->
				</aside>
			</div>
		</div>
	</div>
</section>

<?php get_footer(); ?><!-- load footer.php -->